<template>
	<view class='container symptoms'>
	  <!--左侧栏-->
	  <view class='nav_left'>
		<block v-for="(item,index) in nav" :key='index'>
		  <!-- <view :class="nav_left_items curNav == item.cate_id ? 'active' : ' ' " @tap='switchRightTab' :data-index="index"   :data-id="item.cate_id">{{item.name}}</view> -->
		  <view :class="curNav == item.cate_id ? 'active nav_left_items' : 'nav_left_items' " @tap='switchRightTab($event)' :data-index="index" :data-id="item.cate_id">{{item.name}}</view>
		</block>
	  </view>
	  <!--右侧栏-->
	  <view class='nav_right'>
		<block v-for="(item,index) in nav[curIndex].symneme" :key='index'>
		   <view :class="coloritem == item.title?'#ccc nav_right_items':'red nav_right_items'" @tap="start_incon" :data-id="item.id">
			<text>{{item.title}}</text>
		   </view>
		</block>
	  </view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
			nav:[
			  { 
				name: '消化内科',
				cate_id:1,
				symneme:[
				  {id:'1', title: '慢性心力衰竭' },
				  { id: '99', title: '心脏神经官能症' },
				  { id: '75',title: '慢性心力衰竭' },
				  { id: '5',title:'慢性心力衰竭'},
				  { id: '65',title: '其他病症' },
				]
			   },
			  {
				name: '心血管内科' ,
				cate_id: 2,
				symneme: [
				  { id: '59',title: '心脏神经官能症' },
				  { id: '58',title: '心脏神经官能症' },
				  { id: '57',title: '心脏神经官能症' },
				  { id: '54',title: '心脏神经官能症' },
				  { id: '55',title: '其他病症' },
				]
			   },
			  {
				name: '心内科',
				cate_id: 3,
				symneme: [
				  { id: '56',title: '心脏神经官能症' },
				  { id: '51',id: '5',id: '5',title: '心房颤动' },
				  { id: '52',id: '5',title: '心阴虚' },
				  { id: '53',title: '其他病症' },
				]
			  },
		 
			],
			curNav: 1,
			curIndex:0
			}
		},
		onLoad() {

		},
		methods: {
		  switchRightTab($event){
			  // 获取item项的id，和数组的下标值 
			  console.log($event)
			  this.curNav = $event.currentTarget.dataset.id
			  this.curIndex = $event.currentTarget.dataset.index
		  },
		  //选择好病症
		  start_incon($event){
			let pages = getCurrentPages(); //当前页面
			let prevPage = pages[pages.length-2] ;//上个页面
			var nav = this.nav;
			// 循环二级分类
			for (var i = 0; i < nav.length; i++) {
			  var symneme = nav[i].symneme;
			}
			prevPage.setData({     //直接给上移页面赋值
			  navid: $event.currentTarget.dataset.id
			  // title:  
			}); 
			uni.navigateBack({
			  delta:1
			})
		  },	
		}
	}
</script>

<style>
	.symptoms{
		display: flex;
		width:100%;
		height:100%;
		flex-direction: row
	}
	.nav_left{  
		background:#f5f9fa;
		width:190rpx;
		height: 100vh;
		font-size: 28rpx;
		box-sizing: border-box
	}  
	.nav_right{   
		flex: 1;   
		padding: 0 80rpx;
		font-size: 28rpx;	   
	}  
	.nav_left_items{
		line-height: 90rpx;
		height: 90rpx;
		padding: 0 25rpx;
	}
	.nav_right_items{
		line-height: 90rpx;
		height: 90rpx;
	}
	.nav_right_items:hover{
		color: #108ec9
	}
	.nav_left_items.active{
		background: #fff;
		color: #108ec9;
		font-weight: 600;
	}
</style>
